﻿<style>
    .imp {
        line-height: 28px !important;
    }

    .regUser1 {
        padding: 3px 6px;
    }

    .maskpsd {
        display: none;
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        background-color: rgba(0, 0, 0, 0.1);
        z-index: 999;
    }

    .regUser {
        padding: 2px 6px;
    }

    .maskpsd .register {
        position: absolute;
        width: 40%;
        left: 30%;
        top: 25%;
        border: 1px solid #cccccc;
        border-radius: 8px;
        background-color: #fff;
    }

    .maskpsd .register ul {
        padding: 5px 20px 10px;
    }

    .maskpsd .register ul li {
        position: relative;
        padding: 5px 10px;
        border-bottom: 1px solid #ccc;
        min-height: 40px;
        line-height: 40px;
    }

    .maskpsd .register ul li h3 {
        display: inline-block;
        font-size: 18px;
        font-weight: bold;
        color: #666;
    }

    .maskpsd .register ul li .closeBtn1 {
        position: absolute;
        top: 0;
        right: 0;
    }

    .maskpsd .register ul li .regSpan {
        display: inline-block;
        width: 100px;
        text-align: left;
        margin-right: 10px;
    }

    .maskpsd .register ul li input[type=password] {
        width: 50%;
        height: 40px;
        line-height: 40px;
        border: 1px solid #A9A9A9;
        border-radius: 5px;
        background-color: #F7F7F7;
        font-size: 16px;
        padding-left: 10px;
        box-sizing: border-box;
    }

    .layui-nav-child {
        top: 60px;
    !important;
    }

</style>
<div class="maskpsd">
    <div class="register">
        <ul class="regBox">
            <li>
                <h3>修改密码</h3>
                <span class="xxx closeBtn1">关闭</span>
            </li>
            <li>
                <span class="regSpan">请输入当前密码</span>
                <input type="password" title="" class="uname" id="a_id">
            </li>
            <li>
                <span class="regSpan">请输入新密码</span>
                <input type="password" title="" class="uname" id="ps1">
            </li>
            <li>
                <span class="regSpan">再次输入新密码</span>
                <input type="password" title="" class="uname" id="ps2">
            </li>
            <li>
                <button class="regUser1" id="tj">提交</button>
            </li>
        </ul>
    </div>
</div>
<div class="layui-header">
    <div class="layui-logo">管理后台</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item">
            <a href="javascript:;">
                <img src="http://t.cn/RCzsdCq" class="layui-nav-img"> {{ request.cookies.get('user') }}
            </a>
            <dl class="layui-nav-child imp layui-anim layui-anim-upbit">
                <dd>
                    <a href="#" class="psd">修改密码</a>
                </dd>
                <dd>
                    <a href="/admin/login_out">退出</a>
                </dd>
            </dl>
        </li>

    </ul>
</div>

<div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
        <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
        <ul class="layui-nav layui-nav-tree" lay-filter="test">
            <li class="layui-nav-item layui-nav-itemed">
                <a class="fa" href="javascript:;">首页</a>
                <dl class="layui-nav-child">
                    <dd>
                        <a href="/admin/index.html">欢迎页</a>
                    </dd>
                </dl>
            </li>
            <li class="layui-nav-item layui-nav-itemed">
                <a class="fa" href="javascript:;">内容管理</a>
                <dl class="layui-nav-child">
                    <dd>
                        <a href="/admin/news_list.html">新闻列表</a>
                    </dd>
                    <dd>
                        <a href="/admin/type_list.html">分类列表</a>
                    </dd>
                </dl>
            </li>
            <li class="layui-nav-item layui-nav-itemed">
                <a class="fa" href="javascript:;">用户管理</a>
                <dl class="layui-nav-child">
                    <dd>
                        <a href="/admin/user_list.html">用户列表</a>
                    </dd>
                    <dd>
                        <a href="/admin/user_share.html">分享列表</a>
                    </dd>
                    <dd>
                        <a href="/admin/user_position.html">定位列表</a>
                    </dd>
                </dl>
            </li>
            <li class="layui-nav-item layui-nav-itemed">
                <a class="fa" href="javascript:;">后台管理</a>
                <dl class="layui-nav-child">
                    <dd>
                        <a href="/admin/admin_list.html">管理员列表</a>
                    </dd>
                     <dd>
                        <a href="/admin/version/list.html">版本控制</a>
                    </dd>

                </dl>
            </li>
        </ul>

    </div>
</div>

<script>
    $(document).ready(function () {
        $.ajax({
            url: '/admin/jurisdiction',
            type: 'GET',
            success: function (data) {
                var params = location.pathname;
                $('.layui-side-scroll .layui-nav-item dl dd a').each(function () {
                    $(this).parent().hide()
                    $(this).parent().parent().parent().hide();
                });
                {#                $('.layui-side-scroll .layui-nav-item').hide();#}
                if (data.status == 'success') {
                    $.each(data.arr, function (index2, la2) {
                        $('.layui-nav-item dl dd a').each(function () {
                            if ($(this).html() === la2.route_info) {
                                $(this).parent().parent().parent().show(10);
                                $(this).parent().show(10)
                            }
                        });
                    });

                    var params = location.pathname;
                    $('.layui-nav').children('li').click(function () {
                        $(this).addClass('layui-nav-itemed').siblings().removeClass('layui-nav-itemed');
                    });
                    $(".layui-nav-item dl dd a").each(function (i, v) {
                        var hr = $(v).attr('href');
                        if (params == hr) {
                            $('.layui-nav-tree li').removeClass('layui-nav-itemed');
                            $('.layui-nav-tree li dd').removeClass('layui-this');
                            $(v).parent().addClass("layui-this");
                            $(v).parent().parent().parent().addClass('layui-nav-itemed');
                            return false;
                        } else {
                            var a = document.referrer;
                            var pre_cur = document.referrer.split('/');
                            if (pre_cur.length == 6) {
                                $('a[href="/admin/' + pre_cur[pre_cur.length - 2] + '/' + pre_cur[pre_cur.length - 1] + '"]').parent().addClass("layui-this").siblings().removeClass("layui-this");
                                $('a[href="/admin/' + pre_cur[pre_cur.length - 2] + '/' + pre_cur[pre_cur.length - 1] + '"]').parent().parent().parent().addClass("layui-nav-itemed").siblings().removeClass("layui-nav-itemed");
                            } else {
                                $('a[href="/admin/' + pre_cur[pre_cur.length - 1] + '"]').parent().addClass("layui-this").siblings().removeClass("layui-this");
                                $('a[href="/admin/' + pre_cur[pre_cur.length - 1] + '"]').parent().parent().parent().addClass("layui-nav-itemed").siblings().removeClass("layui-nav-itemed");
                            }
                        }
                    })
                } else if (data.status == 'all') {
                    $('.layui-side-scroll .layui-nav-item dl dd a').each(function () {
                        $(this).parent().show()
                        $(this).parent().parent().parent().show();

                        var params = location.pathname;
                        $('.layui-nav').children('li').click(function () {
                            $(this).addClass('layui-nav-itemed').siblings().removeClass('layui-nav-itemed');
                        });
                        $(".layui-nav-item dl dd a").each(function (i, v) {
                            var hr = $(v).attr('href');
                            if (params == hr) {
                                $('.layui-nav-tree li').removeClass('layui-nav-itemed');
                                $('.layui-nav-tree li dd').removeClass('layui-this');
                                $(v).parent().addClass("layui-this");
                                $(v).parent().parent().parent().addClass('layui-nav-itemed');
                                return false;
                            } else {
                                var a = document.referrer;
                                var pre_cur = document.referrer.split('/');
                                if (pre_cur.length == 6) {
                                    $('a[href="/admin/' + pre_cur[pre_cur.length - 2] + '/' + pre_cur[pre_cur.length - 1] + '"]').parent().addClass("layui-this").siblings().removeClass("layui-this");
                                    $('a[href="/admin/' + pre_cur[pre_cur.length - 2] + '/' + pre_cur[pre_cur.length - 1] + '"]').parent().parent().parent().addClass("layui-nav-itemed").siblings().removeClass("layui-nav-itemed");
                                } else {
                                    $('a[href="/admin/' + pre_cur[pre_cur.length - 1] + '"]').parent().addClass("layui-this").siblings().removeClass("layui-this");
                                    $('a[href="/admin/' + pre_cur[pre_cur.length - 1] + '"]').parent().parent().parent().addClass("layui-nav-itemed").siblings().removeClass("layui-nav-itemed");
                                }
                            }
                        })
                    });
                }
            }
        })

    });


    $('#tj').click(function () {
        var old_password = $('#a_id').val();
        var new1 = $('#ps1').val();
        var new2 = $('#ps2').val();
        if (new1 == new2) {
            $.ajax({
                type: 'post',
                url: '/admin/update_password',
                data: {
                    'old_password': old_password,
                    'password': new2
                },
                success: function (data) {
                    if (data == "success") {
                        alert('修改成功');
                        $(".maskpsd").fadeOut();
                        $('.imp').css('display', 'none')

                    } else {
                        alert('原始密码错误');

                    }
                }
            });
        } else {
            alert('两次密码不一致');

        }
    });

    $('.psd').click(function () {
        $(".maskpsd").fadeIn();
    });
    $('.xxx').click(function () {
        $(".maskpsd").fadeOut();
        $('.imp').fadeOut();
    })
</script>
 
